extends Node3D

@export var max_health: int = 5
@onready var label_3d: Label3D = $Label3D

var age: int = 23
var my_name: String = "mahuapeng"

var current_health: int:
	set(health_in):
		current_health = health_in
		label_3d.text = str(current_health) + "/" + str(max_health)
		label_3d.modulate = Color.RED.lerp(Color.WHITE, float(current_health) / float(max_health))#float很关键
		if current_health <= 0:
			get_tree().reload_current_scene()


func _ready() -> void:
	current_health = max_health
	#print(str(age) + " " + my_name)
	
func take_damage():
	current_health -= 1
	
